﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yitter.IdGenerator;

namespace GWB.Core.TableEntity.Common
{
   public class BaseEntity
    {

        private long _id;

        /// <summary>
        /// Id
        /// </summary>
        [SugarColumn(ColumnDataType = "bigint", IsPrimaryKey = true, ColumnDescription = "主键", IsNullable = false)]
        public long Id
        {
            get
            {
                return _id <= 0 ? YitIdHelper.NextId() : _id;
            }
            set
            {
                _id = value;
            }
        }


        /// <summary>
        /// 是否删除
        /// </summary>
        [SugarColumn(ColumnDataType = "bit", ColumnDescription = "是否删除",  IsNullable = false)]
        public bool IsDeleted { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(ColumnDataType = "datetime", ColumnDescription = "创建时间", IsNullable = false)]
        public DateTime CreateAt { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "创建人", IsNullable = false)]
        public string CreateBy { get; set; }

        /// <summary>
        /// 修改时间
        /// </summary>
        [SugarColumn(ColumnDataType = "datetime", ColumnDescription = "修改时间", IsNullable = true)]
        public DateTime? UpdateAt { get; set; }

        /// <summary>
        /// 修改人
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "修改人", IsNullable = true)]
        public string UpdateBy { get; set; }

        /// <summary>
        /// 删除时间
        /// </summary>
        [SugarColumn(ColumnDataType = "datetime", ColumnDescription = "删除时间", IsNullable = true)]
        public DateTime? DeleteAt { get; set; }

        /// <summary>
        /// 删除人
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "删除人", IsNullable = true)]
        public string DeleteBy { get; set; }
    }
}
